<!----------------引入头部文件-------------------->
<include file="Common/title" />
<script type="text/javascript">
    mui.init()
</script>
<style>
    .cat span{
        font-size: 0.9em;
        border: 1px solid #4192e3;
        border-radius: 5px;
        padding: 0 5px;
        line-height: 2em;
    }
    .gys{
        font-size: 0.9em;
        color:#fe6c00;
    }
    .xl{
        font-size: 0.9em;
        color:darkslategray;
    }
    .title {
        margin: 10px 15px ;
        color: #6d6d72;
        font-size: 15px;
    }
    .text-left{
        width:30%;
    }
    .text-right{
        width:65%;
        text-align:center;
        font-size:0.8em;
    }
    .message{
        position:fixed;
        bottom:90px;
        right:20px;
    }
    .shouc{
        position:fixed;
        bottom:150px;
        right:20px;
    }
</style>
</head>
<body>
<header class="mui-bar mui-bar-nav">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
    <h1 class="mui-title"><?php echo $info['wzmc']?></h1>
</header>
<ul class="mui-table-view" style="margin-top:46px">
    <li class="mui-table-view-cell mui-media">
        <div class="mui-media-body">
            <?php echo $info['wzmc']?>
            <p class='mui-ellipsis'>供  货  商 : <a class="gys" href="{:U('ghs',array('gysno'=>$info['gysno']))}"><?php echo $info['ghs']; ?></a></p>
            <p class='mui-ellipsis cat'>所属类别: <span><a href="{:U('Cat/cat_wzbm',array('flno'=>$info['flno']))}"><?php echo $info['flmc']; ?></a></span></p>
            <p class='mui-ellipsis'>所属系列 : <a class="xl" href="{:U('Cpxl/cpxl_present',array('cpxlno'=>$cpxlno))}"><?php echo $xlmc; ?></a></p>
        </div>
    </li>
</ul>
<div class="title">
    物资参数
</div>
<ul class="mui-table-view">
    <li class="mui-table-view-cell mui-media">
        <a href="javascript:;">
            <div class="mui-pull-right text-right" >有效</div>
            <div class="mui-media-body text-left">
                <p class='mui-ellipsis'>状态</p>
            </div>
        </a>
    </li>
    <li class="mui-table-view-cell mui-media">
        <a href="javascript:;">
            <div class="mui-pull-right text-right" ><?php echo $info['xhgg']?></div>
            <div class="mui-media-body text-left">
                <p class='mui-ellipsis'>型号规格</p>
            </div>
        </a>
    </li>
    <li class="mui-table-view-cell mui-media">
        <a href="javascript:;">
            <div class="mui-pull-right text-right" ><?php echo $info['xh']?></div>
            <div class="mui-media-body  text-left">
                <p class='mui-ellipsis'>型号</p>
            </div>
        </a>
    </li>
    <li class="mui-table-view-cell mui-media">
        <a href="javascript:;">
            <div class="mui-pull-right text-right" ><?php echo $info['zldjmc']?></div>
            <div class="mui-media-body text-left">
                <p class='mui-ellipsis'>质量等级</p>
            </div>
        </a>
    </li>
    <li class="mui-table-view-cell mui-media">
        <a href="javascript:;">
            <div class="mui-pull-right text-right" ><?php echo $info['jldwmc']?></div>
            <div class="mui-media-body text-left">
                <p class='mui-ellipsis'>计量单位</p>
            </div>
        </a>
    </li>
    <li class="mui-table-view-cell mui-media">
        <a href="javascript:;">
            <div class="mui-pull-right text-right" ><?php echo $info['zgf']?></div>
            <div class="mui-media-body text-left">
                <p class='mui-ellipsis'>总规范</p>
            </div>
        </a>
    </li>
    <?php foreach($info['sx'] as $k=>$v):?>
    <li class="mui-table-view-cell mui-media">
        <a href="javascript:;">
            <div class="mui-pull-right text-right" ><?php echo $v['zdysxz']?></div>
            <div class="mui-media-body text-left">
                <p class='mui-ellipsis'>
                    <?php
                    echo $v['sxmc'];
                    if($v['sxdw']!=NULL) echo '('.$v['sxdw'].')';
                  ?>
                </p>
            </div>
        </a>
    </li>
    <?php endforeach;?>
</ul>
<!-------------------添加收藏图标---------------------->
<?php if($userid){ ?>
<div class="flex-container shouc">
    <a id="icon-plus"><span class="mui-icon mui-icon-plus"></span></a>
</div>
<!-----------------------聊天图标----------------------->
<div class="flex-container message">
    <a href="{:U('Chat/chat_window',array('userid'=>$userid,'gysno'=>$info['gysno']))}"><span class="mui-icon mui-icon-chat"></span></a>
</div>
<?php } ?>


<div style="margin-bottom:50px;"></div>
<!------------------引入底部导航卡文件---------------->
<include file="Common/nav"/>

</body>
<script>
    var wzno = '<?php echo $info[wzno];?>'; //物资编码
    var userid  = '{$userid}';  //当前用户ID
    var type = false;  //初始化收藏状态

    //更改当前用户的状态为离线
    function upd_user_online(userid){
        url = '/Home/Online/update_user_online/userid/'+userid+'/user_type/yonghu';
        $.get(url,function(e){
            //alert(e);
        });
    }
    //取出该用户的此产品收藏状态
    function get_collect_type(userid,wzno){
        $.get('/Home/Collect/get_collect_type/userid/'+userid+'/wzno/'+wzno,function(e){
            if(e == true){
                $('#icon-plus span').removeClass('mui-icon-plus');
                $('#icon-plus span').addClass('mui-icon-plus-filled');
                type = true;
            }
        })
    }

    //更改该物资编码的收藏状态
    function set_collect(userid,wzno){
        //如果已经收藏,取消收藏
        if(type == true){
            var btnArray = ['否', '是'];
            mui.confirm('确定取消该产品的收藏？', '操作提示', btnArray, function(e) {
                if (e.index == 1) {
                    $.get('/Home/Collect/del_collect/userid/'+userid+'/wzno/'+wzno,function(a){
                        if(a == true){
                            $('#icon-plus span').removeClass('mui-icon-plus-filled');
                            $('#icon-plus span').addClass('mui-icon-plus');
                            type = false;
                            mui.toast('您已取消该产品的收藏 !');
                        }
                    })
                }
            });
        }else{   //如果没有收藏,添加收藏
            $.get('/Home/Collect/add_collect/userid/'+userid+'/wzno/'+wzno,function(b){
                if(b == true){
                    $('#icon-plus span').removeClass('mui-icon-plus');
                    $('#icon-plus span').addClass('mui-icon-plus-filled');
                    type = true;
                    mui.toast('您成功收藏了该产品 !');
                }
            });
        }
    }

    mui.ready(function(){
        //把当前用户的聊天状态改为退出状态
        if(userid){
            upd_user_online(userid);
        }

        //获取当前物资的收藏状态
        get_collect_type(userid,wzno);

        //给收藏按钮绑定事件
        var sc = document.getElementById('icon-plus');
        sc.addEventListener('tap',function(){
            set_collect(userid,wzno);
        })
    })
</script>
</html>